package com.alice.router.mybatis.test;

import com.alice.mybatisdemo.config.Configuration;
import com.alice.mybatisdemo.config.XMLConfigBuilder;
import com.alice.mybatisdemo.utils.DocumentUtils;
import com.alice.mybatisdemo.utils.Resources;
import com.alice.router.mybatisdemo.config.Configuration;
import com.alice.router.mybatisdemo.config.XMLConfigBuilder;
import com.alice.router.mybatisdemo.utils.DocumentUtils;
import com.alice.router.mybatisdemo.utils.Resources;
import org.dom4j.Document;
import org.junit.Test;

import java.io.InputStream;

public class MybatisTest001 {

    @Test
    public void test(){
        //1.指定全局配置文件路径
        String resource = "SqlMapConfig.xml";
        //2.加载配置文件成InputStream
        //InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(resource);
        InputStream inputStream = Resources.getResourceAsStream(resource);
        //3.根据InputStream获取Document对象
        Document document = DocumentUtils.readDocument(inputStream);
        XMLConfigBuilder builder = new XMLConfigBuilder();
        Configuration configuration = builder.parse(inputStream);
        System.out.println(configuration.toString());
    }
}
